package com.kds.fxtool.domain;

import java.util.ArrayList;
import java.util.List;

public class MenuItem {
    private String id;
    private String title;
    private String icon;
    private String type; // "group", "page", "action"
    private String fxmlFile;
    private String action;
    private boolean expanded;
    private int sortOrder;
    private List<MenuItem> children;

    public MenuItem() {
        this.children = new ArrayList<>();
    }

    public MenuItem(String id, String title, String icon, String type) {
        this();
        this.id = id;
        this.title = title;
        this.icon = icon;
        this.type = type;
    }

    // getters and setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }

    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }

    public String getIcon() { return icon; }
    public void setIcon(String icon) { this.icon = icon; }

    public String getType() { return type; }
    public void setType(String type) { this.type = type; }

    public String getFxmlFile() { return fxmlFile; }
    public void setFxmlFile(String fxmlFile) { this.fxmlFile = fxmlFile; }

    public String getAction() { return action; }
    public void setAction(String action) { this.action = action; }

    public boolean isExpanded() { return expanded; }
    public void setExpanded(boolean expanded) { this.expanded = expanded; }

    public int getSortOrder() { return sortOrder; }
    public void setSortOrder(int sortOrder) { this.sortOrder = sortOrder; }

    public List<MenuItem> getChildren() { return children; }
    public void setChildren(List<MenuItem> children) { this.children = children; }

    public void addChild(MenuItem child) {
        this.children.add(child);
    }

    // 判断是否为叶子节点
    public boolean isLeaf() {
        return children == null || children.isEmpty();
    }

    // 判断是否为分组节点
    public boolean isGroup() {
        return "group".equals(type);
    }
}